<div id="Adding-files"></div>
<div class="header">
<p>
Next: [[cvs: Removing files#Removing files|Removing files]], Up: [[cvs: Adding, removing, and renaming files and directories#Adding, removing, and renaming files and directories|Adding and removing]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Adding-files-to-a-directory"></div>
=== Adding files to a directory ===
<div id="index-Adding-files"></div>

To add a new file to a directory, follow these steps.


* You must have a working copy of the directory. See [[cvs: Getting the source#Getting the source|Getting the source]].


* Create the new file inside your working copy of the directory.


* Use &lsquo;<code>cvs add <var>filename</var></code>&rsquo; to tell <small>CVS</small> that you want to version control the file.  If the file contains binary data, specify &lsquo;<code>-kb</code>&rsquo; (see [[cvs: Handling binary files#Handling binary files|Binary files]]).


* Use &lsquo;<code>cvs commit <var>filename</var></code>&rsquo; to actually check in the file into the repository.  Other developers cannot see the file until you perform this step.

You can also use the <code>add</code> command to add a new
directory.

Unlike most other commands, the <code>add</code> command is
not recursive.  You cannot even type &lsquo;<code>cvs add
foo/bar</code>&rsquo;!  Instead, you have to

<div class="example" style="margin-left: 3.2em">
 $ cd foo
 $ cvs add bar
</div>

<div id="index-add-_0028subcommand_0029"></div>
;<div id="index-cvs-add"></div>Command<nowiki>:</nowiki> <strong>cvs add</strong><em> <nowiki>[</nowiki><code>-k</code> kflag<nowiki>]</nowiki> <nowiki>[</nowiki><code>-m</code> message<nowiki>]</nowiki> files &hellip;</em>

: Schedule <var>files</var> to be added to the repository. The files or directories specified with <code>add</code> must already exist in the current directory.  To add a whole new directory hierarchy to the source repository (for example, files received from a third-party vendor), use the <code>import</code> command instead.  See [[cvs: import--Import sources into CVS, using vendor branches#import&mdash;Import sources into CVS, using vendor branches|import]].

: The added files are not placed in the source repository until you use <code>commit</code> to make the change permanent.  Doing an <code>add</code> on a file that was removed with the <code>remove</code> command will undo the effect of the <code>remove</code>, unless a <code>commit</code> command intervened.  See [[cvs: Removing files#Removing files|Removing files]], for an example.

: The &lsquo;<code>-k</code>&rsquo; option specifies the default way that this file will be checked out; for more information see [[cvs: Substitution modes#Substitution modes|Substitution modes]].

: The &lsquo;<code>-m</code>&rsquo; option specifies a description for the file.  This description appears in the history log (if it is enabled, see [[cvs: The history file#The history file|history file]]).  It will also be saved in the version history inside the repository when the file is committed.  The <code>log</code> command displays this description.  The description can be changed using &lsquo;<code>admin -t</code>&rsquo;.  See [[cvs: admin--Administration#admin&mdash;Administration|admin]].  If you omit the &lsquo;<code>-m <var>description</var></code>&rsquo; flag, an empty string will be used.  You will not be prompted for a description.

For example, the following commands add the file
&lsquo;<tt>backend.c</tt>&rsquo; to the repository:

<div class="example" style="margin-left: 3.2em">
 $ cvs add backend.c
 $ cvs commit -m &quot;Early version. Not yet compilable.&quot; backend.c
</div>

When you add a file it is added only on the branch
which you are working on (see [[cvs: Branching and merging#Branching and merging|Branching and merging]]).  You can
later merge the additions to another branch if you want
(see [[cvs: Merging can add or remove files#Merging can add or remove files|Merging adds and removals]]).


----

<div class="header">
<p>
Next: [[cvs: Removing files#Removing files|Removing files]], Up: [[cvs: Adding, removing, and renaming files and directories#Adding, removing, and renaming files and directories|Adding and removing]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
